###########################################
#REPLICATION FILE FOR VOX POPULI, VOX DEI?
#by ADAM RAMEY
#SECTION 5 ESTIMATION
###########################################

################################################################
#This file estimates politician and voter ideal points for 2010
################################################################


rm(list=ls())
detach(cces)


library(foreign)
library(Zelig)
library(MCMCpack)
library(reshape)
library(basicspace)

##be sure to change the line below so as to indicate where the data and scripts are
setwd("~/Downloads/Replication Materials/")

load("CCES 2010.Rda")

attach(cces)


##Run the three separate scalings

source("~/Downloads/Replication Materials/Estimation for Congress/Scaling House Members Aldrich-McKelvey 2010.R")
source("~/Downloads/Replication Materials/Estimation for Congress/Scaling Senators Aldrich-McKelvey 2010.R")
source("~/Downloads/Replication Materials/Estimation for Congress/Scaling Governors Aldrich-McKelvey 2010.R")



##Make sure to add the voter ideal points to the data...
cces$respondent_ideal_point <- ideal_points

##Also, add CD variable to dataset
cces$cong_district <- paste(V206,"-d-",as.numeric(V276),sep="")

##Write out data...
save(cces, file="CCES 2010.Rda")
